package com.zj.androidcamera.activity;

import android.Manifest;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.KeyEvent;
import android.widget.Button;

import com.zj.androidcamera.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MainActivity extends BaseActivity {

    @BindView(R.id.btn_preview)
    Button btnPreview;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);

    }

    @OnClick(R.id.btn_preview)
    public void onViewClicked() {
        if (!checkCameraPermission()) {
            requestPermissions(Manifest.permission.CAMERA);
        } else {
            Intent intent = new Intent(this, PreviewActivity.class);
            startActivity(intent);
        }
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyDown(keyCode, event))
            return true;
        return super.onKeyDown(keyCode, event);
    }
}
